package com.itheima.mapper;


import com.itheima.domain.Student;
import org.apache.ibatis.annotations.Many;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.mapping.FetchType;

import java.util.List;

public interface StudentMapper {
    @Select("select * from student")
    @Results({
            @Result(column = "id",property = "id",id = true),
            @Result(column = "name",property = "name"),
            @Result(column = "age",property = "age"),

            @Result(
                    property = "courseList",
                    javaType = List.class,
                    column = "cid",
                    many = @Many(select = "com.itheima.mapper.CourseMapper.findBySid",fetchType = FetchType.LAZY)
            )

    })
    List<Student> findAll();
}
